using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;

namespace SkinableFormsLib
{
	public class LWSkinableFormAnimated : LWSkinableForm
	{

		#region Constructors

		#region LWSkinableFormAnimated() : base()
		public LWSkinableFormAnimated() : base()
		{
			_localTimer = new Timer();
			//TODO: (_localTimer.Interval = 100;) this is not so good; the speed of scrolling should be configurable
			_localTimer.Interval = 100;
			_localTimer.Tick += new EventHandler(_localTimer_Tick);
			_localTimer.Enabled = true;
		}
		#endregion

		#endregion

		#region Variables

		#region Private
		private IList<Bitmap> _lwBackgroundBitmaps = new List<Bitmap>();
		private static int cIm = 0;
		private Timer _localTimer;
		#endregion

		#endregion

		#region Methods

		#region Overrides

		#region OnClosing(System.ComponentModel.CancelEventArgs e)
		protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
		{
			this._localTimer.Enabled = false;
		}



		#endregion

		#region AddBackgroundImage(Bitmap im)
		public void AddBackgroundImage(Bitmap im)
		{
			_lwBackgroundBitmaps.Add(im);
		}

		#endregion

		#endregion

		#endregion

		#region Event Handlers

		#region _localTimer_Tick(object sender, EventArgs e)
		void _localTimer_Tick(object sender, EventArgs e)
		{
			if (_lwBackgroundBitmaps.Count > 0)
			{
				cIm = (cIm + 1) % _lwBackgroundBitmaps.Count;
				if (_lwBackgroundBitmaps [cIm] != null)
				{

					Bitmap b = _lwBackgroundBitmaps [cIm];
					if (b.PixelFormat == PixelFormat.Format32bppArgb)
					{
						this._lwBitmap = b;
						SetBitmap();
					}
				}
			}
		}
		#endregion

		#endregion

	}
}
